package com.dc.refactoring._5_简化函数调用._12_ReplaceConstructorWithFactoryMethod.demo1;

/**
 * Description: 工厂函数_通过类型码创建对象
 * @author: gdc
 * @date: 2020/12/11
 * @version 1.0
 */
public class Employee {

    private int type;

    // 原构造函数
    /*public Employee(int type) {
        this.type = type;
    }*/


    private Employee(int type) {
        this.type = type;
    }

    /**
     * 新建工厂函数
     */
    public static Employee create(int type) {
        return new Employee(type);
    }

    public static void main(String[] args){
        // 改造前
        Employee employee1 = new Employee(1);

        // 改造后
        Employee employee2 = Employee.create(1);

    }
}
